<template>
	<view class="templ_orderlist">
		<!-- 订单项 单个 -->

		<view class="tripOrderItem" @click="toDetail(orderitem)">
			<!--  -->
			<view class="trip_head FlexBetween">
				<view class="trip_left FlexAlign">
					<view class="title">
						{{orderitem.order_type_desc}}
					</view>
					<!-- 0-待付款;1-待出行;
					2-出行中;3-已完成;4-已取消 -->
					<view class="trip_staute " v-if="stautshow" :class="'staute' + (orderitem.order_status + 1)">
						{{orderitem.order_status_desc}}
					</view>
				</view>

				<view class="price FlexAlign">
					<view class="pval">
						{{orderitem.order_amount || 0.00}}元
					</view>
					<i class="iconfont icon-jiantou_liebiaoxiangyou"></i>
				</view>

			</view>
			<!--  -->
			<view class="trip_time">
				下单时间：{{orderitem.create_time}}
			</view>
			<!--  -->
			<view class="trip_address">
				<!-- 1-南站直达,2-机场直达,3-福祉车,4-校园车,  -->
				<template v-if="orderitem.order_type < 5">

					<directarea :startval="orderitem.start_addres" :endval="orderitem.end_address"></directarea>
				</template>
				<!-- 直通快线 -->
				<view class="" v-else-if="orderitem.order_type == 5 && orderitem.through_express_rs_snap">
					<travelroute :programme="3" :schedule="orderitem.through_express_rs_snap.schedule"
						:remark="orderitem.through_express_rs_snap.remark"></travelroute>

				</view>
				<!-- 8-广坲城游,  9-周边游 -->
				<template v-else-if="orderitem.order_type > 7">
					<view class="infos_line" v-if="orderitem.ctta_snap">
						套餐名称: {{orderitem.ctta_snap.title || ''}}
					</view>
					<view class="infos_line">
						线路车型: {{orderitem.ctta_snap.car_type || ''}}
					</view>
					<view class="infos_line">
						套餐价格: ￥{{orderitem.order_amount || '0.00'}}
					</view>
				</template>
				<!-- 包车 -->
				<template v-else-if="orderitem.order_type == 7 && orderitem.chartered_bus_apply_snap">

					<directarea :startval="orderitem.chartered_bus_apply_snap.pick_up_point"
						:endval="orderitem.chartered_bus_apply_snap.drop_off_place"></directarea>

				</template>
			</view>

			<template v-if="orderitem.order_type == 7 && orderitem.chartered_bus_apply_snap">
				<view class="infos_line m-t-10" v-if="orderitem.ctta_snap">
					包车车型: {{orderitem.chartered_bus_apply_snap.car_type_desc}}
				</view>
				<view class="infos_line">
					用车开始时间: {{orderitem.chartered_bus_apply_snap.use_start_time}}
				</view>
				<view class="infos_line">
					用车开始结束: {{orderitem.chartered_bus_apply_snap.use_end_time}}
				</view>
				<view class="infos_line">
					联系人: {{orderitem.chartered_bus_apply_snap.contact_name}}
				</view>
				<view class="infos_line">
					联系电话: {{orderitem.chartered_bus_apply_snap.contact_phone}}
				</view>
			</template>

			<!--  -->
			<view class="trip_bottom FlexBetween" v-if="botshow">
				<view class="dele_btn">
					<!-- <i class="iconfont icon-bingji"></i> -->
				</view>
				<view class="operatelist FlexAlign">

					<!-- <view class="operate_btn FlexRow btn_dim" >
						取消订单
					</view>
					<view class="operate_btn FlexRow ">
						开发票
					</view> 
					<view class="operate_btn FlexRow btn_pay" >
						立即支付
					</view> -->
					<view class="operate_btn FlexRow btn_dim" v-if="orderitem.order_status < 2"
						@click.stop="place_Cancel(orderitem.id)">
						取消订单
					</view>
					<view class="operate_btn FlexRow " @click.stop="drawAbill(orderitem)"
						v-if="orderitem.order_status == 3 && !orderitem.invoice_order_id">
						开发票
					</view>
					<view class="operate_btn FlexRow btn_pay" @click.stop="opayment(orderitem.id)"
						v-if="orderitem.order_status == 0">
						立即支付
					</view>
					<!-- <view class="operate_btn FlexRow" v-if="orderitem.order_status == 3">
						再来一单
					</view> -->

				</view>
			</view>
		</view>


	</view>
</template>

<script>
	// 
	// import {
	// 	api_placeCancel,
	// } from "@/api/xtcapi/order.js"
	// 
	import travelroute from "@/bundle4/pages/through/components/travelroute.vue"
	import directarea from "./directarea.vue"
	// 
	export default {
		props: {
			orderitem: {
				type: [Object, String],
				default: () => {
					return {}
				}
			},
			botshow: {
				type: Boolean,
				default: true,
			},
			stautshow: {
				type: Boolean,
				default: true,
			},

		},
		components: {
			travelroute,
			directarea,
		},
		data() {
			return {

			}
		},
		methods: {
			// 取消订单
			place_Cancel(id) {
				// uni.showModal({
				// 	title: '提示',
				// 	content: `确定要取消订单吗？`,
				// 	success: (res) => {
				// 		if (res.confirm) {
				// 			api_placeCancel({
				// 				id
				// 			}).then(res => {
				// 				this.$toast({
				// 					title: '取消订单成功'
				// 				})
				// 				this.ResetRefresh()
				// 			})
				// 		}
				// 	}
				// })
			},
			// 跳转立即支付
			opayment(id) {
				uni.navigateTo({
					url: `/bundle2/pages/payment/payment?from=xtcorder&order_id=${id}`
				})
			},
			// 开发票
			drawAbill(item) {
				let list = [item]
				uni.setStorageSync('invoic_select_list', JSON.stringify(list))
				uni.navigateTo({
					url: '/bundle4/pages/invoice/oinvoicing'
				})
			},

			// 订单详情
			toDetail(item) {
				uni.navigateTo({
					url: `/bundle4/pages/order/orderdetail?id=${item.id}`
				});
			},
		},
	}
</script>

<style lang="scss" scoped>
	@import "@/bundle4/css/Flex.scss";
	@import "@/bundle4/css/dlist.scss";
</style>